<html>
    <head>
    	<meta charset="utf-8">
    	<title>百度输入法</title>
    	<style type="text/css">
	    	#box{width: 150px;margin: 0 auto; height: 150px;}
            
    	</style>
    </head>
    <body>
    	<div id="box">
    		<input type="text" value="1,2,3,4,5"/>
            <input type="button" value="求和" id="btn"/>
            <strong id="s"></strong>
    	</div>
    </body>
    <script type="text/javascript">
        window.onload=function  () {
            var oinput=document.getElementById('box').getElementsByTagName('input');
            var oval=oinput[0].value.split(',');
            //alert(oval);
            var obtn=document.getElementById("btn");
            var osum=document.getElementById('s');
            obtn.onclick=function(){
                var sum=0;
                for(var i=0;i<oval.length;i++){

                    sum+=parseInt(oval[i]);
                    //alert(sum);
                }
                alert(sum);
                osum.innerHTML=sum;
            }
            
        }
    </script>
</html>